package com.acme.bankapp;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.exception.bank.ClientExistsException;
import com.acme.bankapp.service.email.DumbEmailTransportImplementation;
import com.acme.bankapp.service.email.Email;
import com.acme.bankapp.service.email.EmailService;
import com.acme.bankapp.service.event.EmailRegistrationListener;
import com.acme.bankapp.util.BlockingQueue;
import com.acme.bankapp.util.LockingQueue;

public class BankApplication {
    private BankApplication() {
    }

    public static void main(String[] args) {
          try(EmailService emailService = new EmailService(new DumbEmailTransportImplementation(), new LockingQueue<Email>(2))){
              Bank bank = new Bank();
              bank.addListener(new EmailRegistrationListener(emailService));
              for (int i = 0; i < 100; i++) {
                  try {
                      bank.addClient(new Client("John Doe#"+i));
                  } catch (ClientExistsException e) {
                      System.err.println("Client already exists");
                  }
              }
              System.out.println("Done executing!");
          }

    }
}

